﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Loogn.WP.Notification
{
    public class WPToastMessage
    {
        public string Text1 { get; set; }
        public string Text2 { get; set; }

        public string Param { get; set; }

        public string ToXml()
        {
            string toastMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                   "<wp:Notification xmlns:wp=\"WPNotification\">" +
                       "<wp:Toast>" +
                           "<wp:Text1>" + XmlEncoding.Encoding(Text1) + "</wp:Text1>" +
                           "<wp:Text2>" + XmlEncoding.Encoding(Text2) + "</wp:Text2>";
            if (!string.IsNullOrEmpty(Param))
            {
                toastMessage += "<wp:Param>/page1.xaml?value1=1234&amp;value2=9876</wp:Param>";
            }
            toastMessage += "</wp:Toast>" +
                   "</wp:Notification>";
            return toastMessage;
        }

        public byte[] ToBytes()
        {
            var xml = ToXml();
            return Encoding.UTF8.GetBytes(xml);
        }
    }
}
